import java.util.*;

public class Try {
    static double no_touch = Integer.MAX_VALUE;
    static double[][] spend = new double[][] {
            {no_touch, 270000,   no_touch, no_touch, 340000,   no_touch, no_touch, 54360,    no_touch, no_touch, no_touch, no_touch, no_touch, 972500,   no_touch},
            {976040,   no_touch, 270000,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 543600,   no_touch, no_touch, no_touch, no_touch, no_touch},
            {no_touch, no_touch, no_touch, 476000,   no_touch, 466050,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch},
            {no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 750800,   no_touch, 645000,   no_touch, 36000,    no_touch, no_touch, no_touch, 470000},
            {no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch},
            {no_touch, 130000,   no_touch, no_touch, 69400,    no_touch, 476300,   no_touch, no_touch, no_touch, no_touch, 456840,   no_touch, no_touch, no_touch},
            {no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 54430,    no_touch, no_touch},
            {no_touch, no_touch, no_touch, 423000,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 66660,    no_touch, 475500,   no_touch},
            {630000,   no_touch, no_touch, no_touch, 246300,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch},
            {no_touch, 547500,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 246600,   no_touch, no_touch, no_touch, 574000,   no_touch, no_touch},
            {no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 56410,    no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, no_touch},
            {no_touch, no_touch, no_touch, 525120,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 451120,   no_touch, no_touch, no_touch, no_touch},
            {no_touch, no_touch, 133300,   no_touch, no_touch, no_touch, 515610,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 541640,   no_touch},
            {no_touch, no_touch, no_touch, no_touch, 26560,    no_touch, no_touch, no_touch, no_touch, no_touch, 650000,   no_touch, no_touch, no_touch, no_touch},
            {no_touch, no_touch, no_touch, no_touch, no_touch, no_touch, 15440,    no_touch, 651650,   no_touch, no_touch, no_touch, no_touch, no_touch, no_touch}
    };
    static int[] father = new int[15];
    static double spends = 0;

    public static void main(String[] args) {
        List<double[]> list = start();
        List<int[]> ans = getAnswer(list);
        Print(ans, spends);
    }

    public static int find(int x) {
        int temp = x;
        while(father[x] != x) x = father[x];
        father[temp] = x;
        return x;
    }

    public static List<double[]> start() {
        for(int i=0; i<15; i++)  father[i] = i;

        for(int i=0; i<15; i++)  spend[i][i] = 0;
        for(int i=0; i<15; i++) {
            for(int j=i+1; j<15; j++) {
                if(spend[i][j] < spend[j][i])  spend[j][i] = spend[i][j];
                else if(spend[j][i] < spend[i][j])  spend[i][j] = spend[j][i];
            }
        }
        List<double[]> list = new ArrayList<>();
        for(int i=0; i<15; i++) {
            for(int j=i+1; j<15; j++) {
                if(spend[i][j] != Integer.MAX_VALUE)  list.add(new double[]{i, j, spend[i][j]});
            }
        }
        list.sort((o1, o2) -> o1[2] - o2[2]>0? 1: -1);
        return list;
    }

    public static List<int[]> getAnswer(List<double[]> list) {
        List<int[]> ans = new ArrayList<>();

        for(double[] f : list) {
            int x = find((int)f[1]);
            int y = find((int)f[0]);
            if(x != y) {
                father[x] = father[y];
                ans.add(new int[]{x, y});
                spends += f[2];
            }
        }
        return ans;
    }

    public static void Print(List<int[]> ans, double spends) {
        System.out.println("最经济方案:");
        for(int[] f : ans)  System.out.print((char)(f[0]+65) + "<->" + (char)(f[1]+65)+"\t");
        System.out.println("\n总耗费经济代价值:"+spends);
    }
}
